<template>
  <div class="container" style="postition:relative">
    <!-- 轮播图 -->
    <van-swipe v-if="LoginUser.cover.length > 0" class="cover" :autoplay="3000" indicator-color="wite">
      <van-swipe-item v-for="pic in LoginUser.cover">
        <van-image width="100%" height="100%" fit="contain" position="center" :src="pic" />

      </van-swipe-item>
    </van-swipe>


    <!-- 个人信息 -->
    <div class="myBox" style=" position:absolute; top:0; left:0;width: 100%; background:transparent;padding:40px 0px;">
      <div class="L"><img :src="LoginUser.avatar" /></div>
      <div class="C">
        <div class="tit">{{LoginUser.nickname}}</div>
        <div class="sub">{{LoginUser.email}}</div>
      </div>
    </div>
  </div>

  <div class="clear"></div>
  <div class="allkbox"></div>
  <div class="myboxcon">
    <router-link to="/user/base/profile">
      <p>基本资料</p>
      <img src="/assets/images/go.png">
    </router-link>
  </div>
  <div class="myboxcon" v-if="LoginUser.auth=='0'" @click="EmailCheck">
    <p>邮箱认证</p>
    <img src="/assets/images/go.png">
  </div>
  <div class="myboxcon">
    <router-link to="/user/address/index">
      <p>我的收货地址</p>
      <img src="/assets/images/go.png">
    </router-link>
  </div>
  <div class="myboxcon">
    <router-link to="/user/order/index">
      <p>我的订单</p>
      <img src="/assets/images/go.png">
    </router-link>
  </div>
  <div class="myboxcon">
    <router-link to="/user/record/index">
      <p>消费记录</p>
      <img src="/assets/images/go.png">
    </router-link>
  </div>
  <div class="myboxcon">
    <router-link to="/user/record/pay">
    <p>充值记录</p>
    <img src="/assets/images/go.png">
    </router-link>
  </div>
  <div class="myboxcon" @click="logout">
    <p>注销</p>
    <img src="/assets/images/go.png">
  </div>


  <!--底部-->
  <menus></menus>
</template>

<script>
  //引入
  import menus from '@/components/common/menus.vue'

  export default {
    name: 'BaseIndex',
    components: {
      menus
    },
    data() {
      return {
        LoginUser: this.$cookies.get('LoginUser')
      }
    },
    created() {
      var LoginUser = this.$cookies.get('LoginUser');
    },
    methods: {
      // 邮箱认证
      EmailCheck() {
        this.$dialog.confirm({
          title: '标题',
          message: '是否确认发送邮箱认证'
        }).then(async () => {
          // 调用接口
          var success = await this.$api.email({ userid: this.LoginUser.id })

          if (success.result) {
            this.$notify({
              type: 'success',
              message: success.msg,
              duration: 1000,
            })
          } else {
            this.$notify({
              type: "danger",
              message: success.msg,
              duration: 1000,
            })
          }
        })
          .catch(() => { })
      },

      //退出
      logout() {
        this.$dialog.confirm({
          title: '退出登录',
          message: '是否确认退出登录'
        }).then(() => {
          this.$cookies.remove('LoginUser')
          this.$router.push('/')
        })
          .catch(() => { })
      }
    }
  }
</script>
<style>
  .myboxcon a {
    display: block;
    width: 100%;
    height: 100%;
  }

  .container {
    padding-top: 0px;
  }
</style>